import React, { useState } from 'react';
import TodoList from './components/TodoList';
import './App.css';

function App() {
  const [tasks, setTasks] = useState([]);

  const addTask = (task) => {
    if (task.trim() !== '') {
      setTasks([...tasks, { id: Date.now(), text: task }]);
    }
  };

  const deleteTask = (id) => {
    setTasks(tasks.filter((task) => task.id !== id));
  };

  return (
    <div className="app">
      <h1>Список задач</h1>
      <TodoList tasks={tasks} deleteTask={deleteTask} addTask={addTask} />
    </div>
  );
}

export default App;
